<template>
  <div>
    <el-table
      :data="tableData"
      :row-style="rowStyle"
      border>
      <el-table-column
        prop="nickName"
        label="用户昵称">
      </el-table-column>
      <el-table-column
        prop="phone"
        label="微信号码">
      </el-table-column>
      <el-table-column
        prop="phone"
        label="电话号码">
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="1"
      :page-sizes="[10, 20, 50, 100]"
      :page-size="page.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      style="float: right;margin: 20px 150px;"
      :total="page.tatol">
    </el-pagination>
  </div>
</template>

<script>
import request from '@/utils/request'
import { Message } from 'element-ui'
export default {
  data () {
    return {
      tableData: [],
      page: {
        pageSize: 10,
        pageNo: 1,
        tatol: 0
      }
    }
  },
  created () {
    this.search()
  },
  methods: {
    handleSizeChange (val) {
      this.page.pageSize = val
      this.search()
    },
    handleCurrentChange (val) {
      this.page.pageNo = val
      this.search()
    },
    search () {
      request({
        url: '/user/findPage',
        method: 'get',
        params: {
          pageNo: this.page.pageNo,
          pageSize: this.page.pageSize
        }
      }).then(res => {
        if (res.code === '00000000') {
          this.tableData = res.data.data
          this.page.tatol = parseInt(res.data.totalCount)
        } else {
          Message({
            message: res.message,
            type: 'error',
            duration: 5 * 1000
          })
        }
      })
    },
    rowStyle (row) {
      // console.log(row)
      if (row.rowIndex % 2 === 0) {
        return 'background: #ccc'
      }
    }
  }
}
</script>

<style>

</style>
